# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=ssldump
pkgver=1.9
pkgrel=0
pkgdesc="SSLv3/TLS network protocol analyzer"
url="https://github.com/adulau/ssldump"
arch="all"
license="BSD-4-Clause"
subpackages="$pkgname-doc"
makedepends="
	cmake
	json-c-dev
	libnet-dev
	libpcap-dev
	musl-fts-dev
	openssl-dev
	samurai
	"
source="https://github.com/adulau/ssldump/archive/v$pkgver/ssldump-$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_MANDIR=/usr/share/man \
		-DBUILD_SHARED_LIBS=ON \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		-DCMAKE_BUILD_TYPE=None \
		$crossopts
	cmake --build build
}

check() {
	# i want to run tests when upstream adds them
	ctest --test-dir build --output-on-failure --no-tests=ignore
}

package() {
	DESTDIR="$pkgdir" cmake --install build --prefix /usr
	install -Dm644 COPYRIGHT -t "$pkgdir"/usr/share/licenses/$pkgname/
}

sha512sums="
762e09b3d41bcb19553c6290467010fae96633c825617131d90d193b81232aa08d59a4d28d37a32867d6cd92d85ed1a29cf7ece5908b65aa887f7a1e77147511  ssldump-1.9.tar.gz
"
